package com.agenda.mb;

import java.util.Calendar;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

@Entity
@Table(name="commitment")
public class CommitmentMB {
	private long id;
	private String name;
	private String local;
	private String address;
	private String description;
	private PersonMB person;
	public Calendar date = Calendar.getInstance();
	
	public void setId(long id){
		this.id = id;
	}
	
	@Id
	@GeneratedValue
	public long getId(){
		return this.id;
	}
	
	public String getName() {
		return name;
	}
	
	public void setName(String name) {
		this.name = name;
	}
	
	public String getLocal() {
		return local;
	}
	
	public void setLocal(String local) {
		this.local = local;
	}
	
	public String getAddress() {
		return address;
	}
	
	public void setAddress(String address) {
		this.address = address;
	}
	
	public String getDescription() {
		return description;
	}
	
	public void setDescription(String description) {
		this.description = description;
	}	
	
	public void setContact(PersonMB person){
		this.person = person;
	}
	
	@ManyToOne
	@JoinColumn(name="id_person")
	public PersonMB getContact(){
		return this.person;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + (int) (id ^ (id >>> 32));
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		CommitmentMB other = (CommitmentMB) obj;
		if (id != other.id)
			return false;
		return true;
	}
}
